package com.hjy.util;

import com.hjy.pojo.SysUser;
import org.apache.shiro.crypto.hash.Md5Hash;

public class MD5Util {

    public static Boolean isMd5Hash(SysUser sysUser,String password,String salt,Integer count){
        Md5Hash md5Hash = new Md5Hash(password,salt,count);
        boolean result = sysUser.getPassword().equals(md5Hash.toString());
        return result;
    }

    public static Boolean isMd5Hash(SysUser sysUser, String password, String salt){
        Md5Hash md5Hash = new Md5Hash(password,salt,1);
        boolean result = sysUser.getPassword().equals(md5Hash.toString());
        return result;
    }

    public static Boolean isMd5Hash(SysUser sysUser,String password){
        Md5Hash md5Hash = new Md5Hash(password,"salt",1);
        boolean result = sysUser.getPassword().equals(md5Hash.toString());
        return result;
    }

    public static String md5Hash(String password, String salt){
        return new Md5Hash(password,salt,1).toString();
    }

    public static String md5Hash(String password){
        return new Md5Hash(password,"salt",1).toString();
    }

    public static String md5Hash(String password, String salt,Integer count){
        return new Md5Hash(password,salt,count).toString();
    }

}
